package dto;

import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 响应数据传输对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 响应状态
     */
    private ResponseStatus status;
    
    /**
     * 响应消息
     */
    private String message;
    
    /**
     * 响应数据
     */
    private Object data;
    
    /**
     * 请求ID（用于追踪）
     */
    private String requestId;
    
    /**
     * 时间戳
     */
    private Long timestamp;
    
    /**
     * 执行时间（毫秒）
     */
    private Long executionTime;
    
    public Response(ResponseStatus status, String message) {
        this.status = status;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }
    
    public Response(ResponseStatus status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }
    
    /**
     * 创建成功响应
     */
    public static Response success(String message) {
        return new Response(ResponseStatus.SUCCESS, message);
    }
    
    /**
     * 创建成功响应（带数据）
     */
    public static Response success(String message, Object data) {
        return new Response(ResponseStatus.SUCCESS, message, data);
    }
    
    /**
     * 创建失败响应
     */
    public static Response error(String message) {
        return new Response(ResponseStatus.ERROR, message);
    }
    
    /**
     * 创建失败响应（带数据）
     */
    public static Response error(String message, Object data) {
        return new Response(ResponseStatus.ERROR, message, data);
    }
    
    /**
     * 响应状态枚举
     */
    public enum ResponseStatus {
        SUCCESS,
        ERROR,
        NOT_FOUND,
        INVALID_REQUEST
    }
} 